//
//$Id: types.h 679 2011-03-12 16:50:06Z andrew.tsyganov $
#pragma once

const std::string kAppName           = "refam";
const std::string kAppURL            = "http://code.google.com/p/heo/";
const std::string kAppVersion        = "1.0";

const std::string kXmlVersionAttr    = "version";
const std::string kXmlVersion        = "1.0";

const std::string kAppXmlNode        = "refam";
const std::string kAppXmlURLAttr     = "url";
const std::string kAppXmlVersionAttr = "version";

class IntSet;
class Grid;


typedef IntSet Subset; // integer subsets
typedef size_t u_t;    // unsigned type

typedef enum {PARENTHESES = 0, BRACKETS = 1, BRACES = 2, LATEX_BRACES = 3, NO_BRACKETS = 4} Brackets_Type; 
typedef enum {TXT = 0, LATEX = 1, HTML = 2} Labels_Type;
typedef enum {B = 0, KB = 1, MB = 2} Memory_Units;

struct States_Pair
{ 
	u_t first_, second_; 
	States_Pair(u_t const first, u_t const second): first_(first), second_(second) {};
};

struct Labels_Prefix
{
	std::string symbols_pfx_;
	std::string states_pfx_;
	Labels_Prefix(std::string const& symbols_pfx, std::string const& states_pfx): symbols_pfx_(symbols_pfx), states_pfx_(states_pfx) {};
};

const Labels_Prefix kDefaultLabelsPfx("s", "q");

class Label: public std::string
{
public:
	Label(): std::string() {}
	Label(std::string const& s): std::string(s) {}
	Label(char const* s): std::string(s) {}
	u_t calc_Size() const { return this->size(); }
	std::string to_String() const { return *this; }
	unsigned serialize(unsigned char* buf) const;
	unsigned deserialize(unsigned char const* buf);
};

struct Transition
{
	u_t src_id_, sym_id_, dst_id_;
	Transition(u_t const src_id, u_t const sym_id, u_t dst_id): src_id_(src_id), sym_id_(sym_id), dst_id_(dst_id) {};
};

bool operator ==(Transition const& lhs, Transition const& rhs);

typedef std::vector<u_t> Path;
typedef Path Loop;
typedef Loop Simple_Loop;

class Bool_Matrix: public std::vector< std::vector<char> >
{
public:
    u_t nrows_, ncols_, nones_;
	Bool_Matrix() { nones_ = 0; };
    void init(u_t const nrows, u_t const ncols);
	void set(u_t i, u_t j);
	void reset(u_t i, u_t j);
	void cover(Grid const& g);
	//void uncover(Grid const& g);
	u_t get_Ones_Num() const { return nones_; };
};

class Subset_Matrix: public std::vector< std::vector<Subset> >
{
public:
	u_t nrows_, ncols_;
    void init(u_t const nrows, u_t const ncols);
    void clear();
	void remove();
	void cover(Grid const& g, u_t const element);
	void cover(std::vector<Grid> const& vg, u_t const fixed_num = 0);
    //void print_TXT(std::ostream& os) const;
};

//EOF!
